iOS RxDataSources

RxDataSource 的本质就是使用 RxSwift 对 UITableView 和 UICollectionView 的数据源做了一层包装

1. UITableView

数据源类型:RxTableViewSectionedReloadDataSourceRxTableViewSectionedAnimatedDataSource

2. UICollectionView

数据源类型:RxTableViewSectionedReloadDataSourceRxCollectionViewSectionedAnimatedDataSource

3. ModelType

模型类型:SectionModelAnimatableSectionModel

4. 使用动画数据源,自定义模型需遵守IdentifiableType协议

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class NewsListModel: Object,Mappable {
@objc dynamic var publishTime: String? // 发布时间
@objc dynamic var category: String? // 类型
@objc dynamic var source: String? // 来源
@objc dynamic var newsId: String? // 新闻ID
@objc dynamic var title: String? // 标题
@objc dynamic var newsImg: String? //新闻小图片url

required convenience init?(map: Map) {
self.init()
}

func mapping(map: Map) {
publishTime <- map["publishTime"]
category <- map["category"]
source <- map["source"]
newsId <- map["newsId"]
title <- map["title"]
newsImg <- map["newsImg"]
}
}

extension NewsListModel: IdentifiableType {
var identity: NewsListModel {
return self
}

typealias Identity = NewsListModel
}

5. Demo

坚持原创技术分享,您的支持将鼓励我继续创作!